package com.cyy.springbootinit.controller;

import com.cyy.springbootinit.common.BaseResponse;
import com.cyy.springbootinit.common.ResultUtils;
import com.cyy.springbootinit.model.entity.User;
import com.cyy.springbootinit.service.UserService;
import com.cyy.springbootinit.service.impl.BigModelNew;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/bigModel")
@Slf4j
public class BidModelController {
    @Resource
    private UserService userService;
    @GetMapping("/bid")
    public BaseResponse<String> bid(String newQuestion, HttpServletRequest request) throws Exception {
        System.out.println("收到新问题：" + newQuestion);
        User loginUser = userService.getLoginUser(request);
        BigModelNew model = new BigModelNew(loginUser.getId().toString(), false);
        String answer = model.askQuestion(newQuestion);
        System.out.println("大模型回答：" + answer);
        return ResultUtils.success(answer);
    }
}
